import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'
import store from '@/store/index'
Vue.use(VueRouter)

const router = new VueRouter({
  routes,
  mode: 'hash',
})
router.beforeEach((to, from, next) => {
  if (to.meta?.islogin) {
    if (store.state.admin.token !== '') {
      next()
    } else {
      next('/login')
    }
  } else {
    next()
  }
})
export default router
